using System;
using UnityEngine;

namespace RGuang.PlathformCtrl
{
    /// <summary>
    /// 玩家土狼时间
    /// </summary>
    [CreateAssetMenu(menuName = "Data/StateMachine/PlayerState/CoyoteTime", fileName = "PlayerState_CoyoteTime")]
    public class PlayerState_CoyoteTime : PlayerState
    {

        [SerializeField] float runSpeed = 5f;
        [SerializeField] float coyoteTime = 0.1f;//土狼持续时间
        public override void Enter()
        {
            base.Enter();
            player.SetUseGravity(false);
        }
        public override void Exit()
        {
            player.SetUseGravity(false);
        }
        public override void LogicUpdate()
        {

            if (input.Jump)
            {
                stateMachine.SwitchState(typeof(PlayerState_JumpUp));
            }

            if (stateDuration > coyoteTime || !input.Move)
            {
                stateMachine.SwitchState(typeof(PlayerState_Fall));
            }

        }

        public override void PhysicUpdate()
        {
            player.Move(runSpeed);
        }
    }
}
